<?php
/**
 * SmartyTpl.php	smarty
 *
 * @package		
 * @Copyright	(c) All rights reserved
 * @Author		skyCrack <skyCrack@126.com>
 * @Version		$Id$
 */

require_once 'Smarty/Smarty.class.php';

class SmartyTpl extends Smarty
{
	private $_options	=	array(
		'left_delimiter'	=>	'{',
		'right_delimiter'	=>	'}',
		'template_dir'		=>	'tpl/',
		'compile_dir'		=>	'tpl_c/',
		'config_dir'		=>	'inc',
		'cache_dir'			=>	'',
		'caching'			=>	false
	);
	
	public function __construct($options = array()) {
		parent::__construct();
		$this->setOptions($options);
	}
	
	public function setOptions($options) {
		foreach ( $this->_options as $name => $value ) {
			if ( isset($options[$name]) ) {
				$this->_options[$name]	=	$options[$name];
				$value	=	$options[$name];
			}
			
			$this->$name	=	$value;
		}
	}
	
	/**
	 * magic function to set template values
	 *
	 * @param string $name template var name
	 * @param string $value value
	 */
	public function __set($name, $value) {
		$this->assign($name, $value);
	}
}
?>